﻿/**
 * Peter
 * Created by: Peter Development Team
 *    http://peter.codeplex.com/
 * 
 * GNU General Public License version 2 (GPLv2)
 *    http://peter.codeplex.com/license
 *
 *  This code is provided on an AS IS basis, with no WARRANTIES,
 *  CONDITIONS or GUARANTEES of any kind.
 *
 **/

using ICSharpCode.AvalonEdit.Document;
using Peter.Common.Interfaces;

namespace Peter.Common
{
   /// <summary>
   /// A base implementation of the peter text document.
   /// </summary>
   public abstract class PeterTextDocument : PeterFileDocument, IPeterTextDocument
   {
      /// <summary>
      /// Event that occurs when the text of the document changes.
      /// </summary>
      public event TextEventHandler TextChanged;

      /// <summary>
      /// Gets the text of the document.
      /// </summary>
      public abstract string Text { get; }

      /// <summary>
      /// Raises the text changed event.
      /// </summary>
      protected void RaiseTextChanged ()
      {
         if (this.TextChanged != null)
            this.TextChanged (this, new TextEventArgs (this.Text));
      }

      /// <summary>
      /// Scrolls to the given offset.
      /// </summary>
      /// <param name="offset">Offset to scroll to.</param>
      public virtual void ScrollToOffset (int offset)
      {
      }

      /// <summary>
      /// Scrolls the document to the given location.
      /// </summary>
      /// <param name="location">Location to scroll to.</param>
      public virtual void ScrollToLocation (TextLocation location)
      {

      }
   }
}
